package com.lphj.datainterface.handle;

import com.lphj.datainterface.component.Config.ReadOtherConfig;
import com.lphj.datainterface.entity.TCustomerStore;
import com.lphj.datainterface.service.TCustomerStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Component
public class TCustomerStoreHandle {

    @Autowired
    TCustomerStoreService tCustomerStoreService;

    @Autowired
    ReadOtherConfig readOtherConfig;

    @Transactional
    public int addTCustomer() {
        int count = 0;
        List<String> cumNOList = tCustomerStoreService.getCustomerCumNO();
        //先清空公司客户表tCustomerStore
        tCustomerStoreService.delTCustomerStore();
        for(String s : cumNOList) {
            TCustomerStore tCustomerStore = new TCustomerStore();
            tCustomerStore.setsCumNO(s);
            tCustomerStore.setsStoreNO(readOtherConfig.getStoreNO());
            tCustomerStoreService.addTCustomerStore(tCustomerStore);
        }
        return count;
    }
}
